<%@ page language="java"
	import="java.util.*,java.text.*,java.sql.*,zuoye5_28.*"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<%
	try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		Connection con = null;
		try {
			con = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/soarroad?useSSL=false",
					"root", "19890909w");
			System.out.println("连接成功！ ");
			Scanner sc = new Scanner(System.in);
			String sql = "select * from `subject`";
			PreparedStatement sm = null;
			sm = con.prepareStatement(sql);
			ResultSet rs = sm.executeQuery(sql);
			while(rs.next()){
			out.println(rs.getInt("id")+" "+rs.getString("subjectname")+" "+rs.getInt("classhour")+" "+rs.getInt("gradeid"));
			%><br/><% 
			}
			} catch (SQLException e) {
			e.printStackTrace();
			} finally {
				if (null != con) {
					try {
						con.close();
						System.out.println("关闭连接!");
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}

			}
			
%>
</body>
</html>